﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;

namespace OracleDAL.ResourceManage
{
    public class ResMaintain
    {
        /// <summary>
        /// 获取资源信息表格字段
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns></returns>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select TABLENAME,ISRAGATORY,ISSTATISTIC,SERIAL,GETRULE,ISADDITIVEINTO,");
            strSql.Append(" ISEDITABLEINTO,CODEINPUTINTO,CHANGESETNULL,CUSTOMSELECT,TREEBRANCHTYPES,ENFIELD,");
            strSql.Append(" TREEROOTRESID,REMARK,ISTRANSITION,TRANSTABLE,TRANSCOL,TRANSEDCOL,VALUETYPE,ISAUTOCODE,");
            strSql.Append(" PUBLICVISIBLE,CHFIELD,ISKEY,DATATYPE,ISNULL,ISVISIBLE,ISEDITABLE,ISADDITIVE ");
            strSql.Append(" FROM CFG_RESOURCE_FIELDS ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DBUtility.OracleHelper.Query(strSql.ToString());
        }
        public DataSet GetQuery(string strSql)
        {
            return DBUtility.OracleHelper.Query(strSql.ToString());
        }
        public Model.ResourceManage.ResMaintain GetExcutState(string strSqlInsert)
        {
            Model.ResourceManage.ResMaintain model = new Model.ResourceManage.ResMaintain();

            //OracleParameter[] parameters = {
            //        new OracleParameter("sqlinsert", OracleType.VarChar,1024),new OracleParameter("issucces",OracleType.VarChar,10)};
            //parameters[0].Value = strSqlInsert;
            //parameters[1].Direction = ParameterDirection.Output;
            //int getresult;
            //DBUtility.OracleHelper.RunProcedure("com_insert_proc", parameters, out getresult);
            //model.GetResult = getresult;
            //return model;

            int temp = DBUtility.OracleHelper.ExecuteSql(strSqlInsert);
            model.GetResult = temp;
            return model;
        }
        public string getFuJianName(string FuJianId)
        {
            string FuJianName = "";
            string strSql = "select name from accessoriesinfo where id='" + FuJianId + "'";


            OracleDataReader dr = DBUtility.OracleHelper.ExecuteReader(strSql);
            while (dr.Read())
            {
                FuJianName = dr["name"].ToString();
            }

            return FuJianName;
        }
    }
}
